package com.yuwei.service

import androidx.recyclerview.widget.GridLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.yuwei.base.BaseViewFragment
import com.yuwei.common.entity.MenuEntity
import com.yuwei.common.path.RouterPath
import com.yuwei.service.adapter.ServiceMenuAdapter
import com.yuwei.service.databinding.FragmentServiceBinding

@Route(path = RouterPath.MODULE_SERVICE_FRAGMENT)
class ServiceFragment : BaseViewFragment<FragmentServiceBinding>() {
    private val list = mutableListOf<MenuEntity>().apply {
        add(MenuEntity(R.drawable.service_menu_image1, "车辆管理"))          // 汽车图标
        add(MenuEntity(R.drawable.service_menu_image2, "车位管理"))     // 地锁图标
        add(MenuEntity(R.drawable.service_menu_image3, "访客管理"))    // 证件图标
        add(MenuEntity(R.drawable.service_menu_image4, "维修管理"))      // 图表图标
        add(MenuEntity(R.drawable.service_menu_image5, "公告管理"))      // 电脑图标
        add(MenuEntity(R.drawable.service_menu_image6, "考勤管理"))  // 闹钟图标
        add(MenuEntity(R.drawable.service_menu_image7, "即时通讯"))      // 对话气泡图标
        add(MenuEntity(R.drawable.service_menu_image8, "设备管理"))      // 电脑图标
        add(MenuEntity(R.drawable.service_menu_image9, "房源信息"))           // 房屋图标
        add(MenuEntity(R.drawable.service_menu_image10, "物业报修"))        // 房屋图标
        add(MenuEntity(R.drawable.service_menu_image11, "巡检管理"))  // 放大镜图标
        add(MenuEntity(R.drawable.service_menu_image12, "月卡会员"))        // 卡片图标
    }
    private val serviceMenuAdapter = ServiceMenuAdapter()
    override fun initView() {
        serviceMenuAdapter.data.addAll(list)
        serviceMenuAdapter.notifyDataSetChanged()
        binding.serviceRv.adapter = serviceMenuAdapter
        binding.serviceRv.layoutManager = GridLayoutManager(requireContext(), 3)
        serviceMenuAdapter.setOnItemClickListener { adapter, view, position ->
            if (serviceMenuAdapter.data[position].title == "车辆管理"){
                ARouter.getInstance().build(RouterPath.CAR).navigation()
            }
            if (serviceMenuAdapter.data[position].title == "车位管理"){
                ARouter.getInstance().build(RouterPath.PARKING_SPACE_MANAGEMENT).navigation()
            }
            if (serviceMenuAdapter.data[position].title == "访客管理"){
                ARouter.getInstance().build(RouterPath.APPOINTMENTS_URL).navigation()
            }
            if (serviceMenuAdapter.data[position].title == "维修管理"){
                ARouter.getInstance().build(RouterPath.ORDERS).navigation()
            }
            if (serviceMenuAdapter.data[position].title == "公告管理"){
                ARouter.getInstance().build(RouterPath.ATTENDANCE).navigation()
            }
            if (serviceMenuAdapter.data[position].title == "考勤管理"){
                ARouter.getInstance().build(RouterPath.ATTENDANCE).navigation()
            }
            if (serviceMenuAdapter.data[position].title == "即时通讯"){
                ARouter.getInstance().build(RouterPath.ATTENDANCE).navigation()
            }
            if (serviceMenuAdapter.data[position].title == "设备管理"){
                ARouter.getInstance().build(RouterPath.DEVICES).navigation()
            }
            if (serviceMenuAdapter.data[position].title == "房源信息"){
                ARouter.getInstance().build(RouterPath.PROP).navigation()
            }
            if (serviceMenuAdapter.data[position].title == "物业报修"){
                ARouter.getInstance().build(RouterPath.ORDERS).navigation()
            }
            if (serviceMenuAdapter.data[position].title == "巡检管理"){
                ARouter.getInstance().build(RouterPath.INSPECTION_ORDERS).navigation()
            }
            if (serviceMenuAdapter.data[position].title == "月卡会员"){
                ARouter.getInstance().build(RouterPath.YK_MODULE).navigation()
            }

        }

    }

    override fun initData() {

    }

}